package demo.pattern.eventmode;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName EventSource
 * @Description
 * @Author 47980
 * @Date 2020/6/24 20:47
 * @Version V_1.0
 **/
public class EventSource {

    private List<EventListener> listenerList = new ArrayList<>();

    public void register(EventListener eventListener) {
        listenerList.add(eventListener);
    }

    public void publishEvent(Event event) {
        listenerList.forEach(eventListener -> {
            eventListener.processEvent(event);
        });
    }
}
